import java.util.Comparator;
import java.util.Random;

/**
 * Created with IntelliJ IDEA
 * Description:
 * User: Administrator
 * Data: 2023 - 06 - 05
 * Time: 19:51
 */

class Student{
    private String name;
    private String gender;
    private static String classRoom;
    //实例代码块
    {
        this.name = "ZhangSan";
        this.gender = "man";
        System.out.println("instance");
    }
    //静态代码块
    static {
        classRoom = "4";
        System.out.println("static");
    }
    public Student(){
        System.out.println("Student init");
    }
    public static void main(String[] args) {
        Student s1 = new Student();
        Student s2 = new Student();
    }
}





interface USB{
    void openDevice();
    void closeDevice();
}
class KeyBoard implements USB{
    @Override
    public void openDevice(){
        System.out.println("打开键盘");
    }
    @Override
    public void closeDevice(){
        System.out.println("关闭键盘");
    }
    public void inPut(){
        System.out.println("键盘输入");
    }
}
class Computer{
    public void useDevice(USB usb){//向上转型
        usb.openDevice();//动态绑定
        if(usb instanceof KeyBoard){
            KeyBoard keyBoard =(KeyBoard)usb;//向下转型
            keyBoard.inPut();
        }
        usb.closeDevice();//动态绑定
    }
    public static void main(String[] args){
        Computer computer = new Computer();
        computer.useDevice(new KeyBoard());//使用键盘
    }
}














